package com.easytopit.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.easytopit.demo.dao.UserDao;

@Controller
public class UserController {
	
	@Autowired
	private UserDao userDao;
	
	@RequestMapping("/reg")
	public String regPage(){
		return "reg";
	}
	
	@RequestMapping(value="/reg.do",method = RequestMethod.POST)
	public void reg(String name,String passwd,String phone,ModelMap modelMap){
		if(userDao.checkName(name) == null){
			userDao.insert(name, passwd, phone);
		}
		modelMap.put("mes", "该用户名已被注册");
	}
}